﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title>new document </title>
        <link rel="stylesheet" href="css\bootstrap.css">
        <script src="js/jquery-1.11.3.js">
        </script>
        <script src="js/bootstrap.js">
        </script>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" charset="UTF-8">
    </head>
    <body>
        <header>
            <nav class="navbar navbar-default" style="margin:auto">
                <div class="container">
                    <ul class="nav nav-tabs">
                        <li>
                            <a href="dcxt.php" class="btn btn-default" type="button" style="border:0px;margin:8px 0">
                                点餐系统
                            </a>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                订单管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
                                <li>
                                    <a href="list.php">订单列表</a>
                                </li>
                                <li>
                                    <a href="history.php">订单记录</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                菜品管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
							
                                <li>
                                    <a href="dishappend.php">添加菜品</a>
                                </li>
                                <li>
                                    <a href="dishlist.php">菜品列表</a>
                                </li>
								 <li>
                                    <a href="dishtype.php">添加菜品类型</a>
                                </li> <li>
                                    <a href="typelist.php">菜品类型列表</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                餐桌管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
                                <li>
                                    <a href="appendtable.php">添加餐桌</a>
                                </li>
                                <li>
                                    <a href="tablelist.php">餐桌列表</a>
                                </li>
                            </ul>
                        </li>
                        <li>
                            <button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown" style="border:0px;margin:8px 0;">
                                登录管理<span class="caret"></span>
                            </button>
                            <ul class="dropdown-menu" aria-labelledby="lx">
                                <li>
                                    <a href="modifier.php">修改登陆信息</a>
                                </li>
                                <li>
                                    <a href="#">退出登录</a>
                                </li>
                            </ul>
                        </li>
                    </ul>
                </div>
            </nav>
        </header>
		<div class="container">
			<div class="row" style="width:60%">
				<div class="col-xs-3 paga-left">
				<a href="dcxt.php" class="btn btn-default btn-block">返回主页</a>
				</div>
				<div class="col-xs-8 panel panel-default">
					<div class="panel-heading">
						 <span class="glyphicon glyphicon-edit">修改登陆信息</span>
					</div>
					<div class="panel-body">
						<div class="row">
							<form class="form-horizental" method="post">
								<div class="form-group">
									<div class="text-center col-xs-4" style="font-weight:800">原登录名:</div>
									<div class="input-group col-xs-6">
										<input type="text" class="form-control" placeholder="username" name="username">
									</div>
								</div>
								<div class="form-group">
									<div class="text-center col-xs-4" style="font-weight:800">原密码:</div>
									<div class="input-group col-xs-6">
										<input type="password" class="form-control" placeholder="password" name="password">
									</div>
								</div>
								<div class="form-group">
									<div class="text-center col-xs-4" style="font-weight:800">新登录名:</div>
									<div class="input-group col-xs-6">
										<input type="text" class="form-control" placeholder="newusername" name="newusername">
									</div>
								</div>
								<div class="form-group">
									<div class="text-center col-xs-4" style="font-weight:800">新密码:</div>
									<div class="input-group col-xs-6">
										<input type="password" class="form-control" placeholder="newpassword1" name="newpassword1">
									</div>
								</div>
								<div class="form-group">
									<div class="text-center col-xs-4" style="font-weight:800">新密码:</div>
									<div class="input-group col-xs-6">
										<input type="password" class="form-control" placeholder="newpassword2" name="newpassword2">
									</div>
									<div>&nbsp</div>
									<div class="col-xs-7">&nbsp</div>
									<button type="submit" class="btn btn-primary col-xs-3">修改</button>
								</div>
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
	</body>
</html>
<?php
@$username=$_REQUEST['username'];
@$psaaword=$_REQUEST['password'];
@$newusername=$_REQUEST['newusername'];
@$newpassword1=$_REQUEST['newpassword1'];
@$newpassword2=$_REQUEST['newpassword2'];
if(!empty($username) && !empty($psaaword)){
$pdo=new PDO('mysql:dbname=test;charset=utf8','root');
$sel=$pdo->prepare('select * from entry where username=:username');
$isok=$sel->execute(array('username'=>$username));
$pwd=$sel->fetch(PDO::FETCH_NAMED);
if($isok){
if(empty($pwd)){ exit;}echo $username;
if($psaaword == $pwd['password']){
	if($newpassword1 == $newpassword2){
		$sel1=$pdo->prepare('update entry set username=:newusername,password=:newpassword where username=:username');
		$isok=$sel1->execute(array('newusername'=>$newusername,'newpassword'=>$newpassword1,'username'=>$username));
	} else { echo "新密码输入不一致";}
} else { echo "用户名或密码错误";}
}
}
?>